package com.dyh.quickdemozwei;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.junit.jupiter.api.Test;


import java.util.*;

public class TestSeq {

    @Setter@Getter@NoArgsConstructor@AllArgsConstructor
    class Order{
        Long price;
        Long num;
        String user;
        int type;//0 买 1卖
    }

    /*买是从低到高*/

    private final NavigableMap<Long, List<Order>> buyMap = new TreeMap<>();

    /*买是从高到低*/
    private final NavigableMap<Long, List<Order>> sellMap = new TreeMap<>(Collections.reverseOrder());

    @Test
    public void test(){
        //init

        sellMap.put(100L,
                Lists.newArrayList(
                        new Order(100L,10L,"ytq",1),
                        new Order(100L,20L,"wy",1),
                        new Order(90L,20L,"ytq",1)
                )
        );

        buyMap.put(80L,
                Lists.newArrayList(
                        new Order(80L,10L,"a",0),
                        new Order(85L,20L,"b",0),
                        new Order(90L,20L,"c",0)
                )
        );


//        Order buyOrder = new Order(110L,30L,"dyh",0);
        Order buyOrder = new Order(100L,30L,"dyh",0);
        /*能找到100 90*/

        NavigableMap<Long, List<Order>> sellOrdersL1= sellMap.headMap(buyOrder.getPrice(),true);
        /*110->0*/
        /*SortedMap<K,V> headMap(K toKey);*/

        System.out.println();
    }
}
